﻿@using UsedBookTradeSystem.Models.Entity
@using UsedBookTradeSystem.Models.Dtos.OutputDtos
@{
    ViewData["Title"] = "CheckOut";
    Layout = "~/Views/Shared/_Layout.cshtml";
    User userInfo = ViewBag.User;
    List<CartInfoOutput> carts = ViewBag.Cart;
}

<section class="py-5 bg-light">
    <div class="container">
    <div class="row px-4 px-lg-5 py-lg-4 align-items-center">
        <div class="col-lg-6">
        <h1 class="h2 text-uppercase mb-0">结算</h1>
        </div>
        <div class="col-lg-6 text-lg-end">
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb justify-content-lg-end mb-0 px-0 bg-light">
            <li class="breadcrumb-item"><a class="text-dark" href="/Home/Shop">商城</a></li>
            <li class="breadcrumb-item"><a class="text-dark" href="/Cart/Index">购物车</a></li>
            <li class="breadcrumb-item active" aria-current="page">结算</li>
            </ol>
        </nav>
        </div>
    </div>
    </div>
</section>
<section class="py-5">
    <!-- BILLING ADDRESS-->
    <h2 class="h5 text-uppercase mb-4">收货信息</h2>
    <div class="row">
    <div class="col-lg-8">
            <form action="/Cart/MakeOrder" method="post">
        <div class="row gy-3">
            <div class="col-lg-6">
            <label class="form-label text-sm text-uppercase">收货人姓名</label>
            <input class="form-control form-control-lg" type="text" id="Name" name="Name" placeholder="请输入收货人姓名" value="@userInfo.UserName" required>
            </div>
            <div class="col-lg-6">
            <label class="form-label text-sm text-uppercase">电话号码 </label>
                <input class="form-control form-control-lg" type="number" id="phone" name="Tel"  placeholder="请输入电话号码" readonly value="@userInfo.Tel" required>
            </div>
            <div class="col-lg-12">
            <label class="form-label text-sm text-uppercase">收货地址 </label>
            <input class="form-control form-control-lg" type="text" id="address" name="Address" placeholder="请输入收货地址" value="@userInfo.Address" required>
            </div>
            <div class="col-lg-12 form-group">
            <button class="btn btn-dark" type="submit">购买</button>
            </div>
        </div>
        </form>
    </div>
    <!-- ORDER SUMMARY-->
    <div class="col-lg-4">
        <div class="card border-0 rounded-0 p-lg-4 bg-light">
        <div class="card-body">
            <h5 class="text-uppercase mb-4">支付金额</h5>
            <ul class="list-unstyled mb-0">
                        @foreach (var item in carts)
                        {
                            <li class="d-flex align-items-center justify-content-between"><strong class="small fw-bold">@item.BookName</strong><span class="text-muted small">￥@item.TotolPrice</span></li>
                            <li class="border-bottom my-2"></li>
                        }
            <li class="d-flex align-items-center justify-content-between"><strong class="text-uppercase small fw-bold">总价</strong><span>￥@carts.Sum(x=>x.TotolPrice)</span></li>
            </ul>
        </div>
        </div>
    </div>
    </div>
</section>

